/*
    The NeonX Library

    Copyright (c) 2013 darkcat

    Code covered by the MIT License
*/

#pragma once

// nx...
#include "config/general.h"
// NX_ALLOC
#include "memory/memalloc.h"
// nx::vector
#include "container/vector.h"
// Special assign algorithm
#include "algorithm/assign.h"

// std::priority_queue
#include <queue>

//////////////////////////////////////////////////////////////////////////
NX_BEG
//////////////////////////////////////////////////////////////////////////

template
<
    typename Type_, typename Seq_ = nx::vector<Type_>,
    typename Comp_ = std::less<typename Seq_::value_type>
>
class priority : public std::priority_queue<Type_, Seq_, Comp_>
{
public:
    typedef std::priority_queue<Type_, Seq_, Comp_> base_t;

public:
    explicit priority(const Comp_& c = Comp_(),
                      const Seq_& s = Seq_())
        : base_t(c, s)
    {}

    template <typename Iterator_>
    priority(Iterator_ f,
             Iterator_ l,
             const Comp_& c = Comp_(),
             const Seq_& s = Seq_())
        : base_t(f, l, c, s)
    {}
};

/*
    Special assign algorithm
*/

template <typename T_, typename S_, typename C_>
struct Push<priority<T_, S_, C_> >
{
    typedef priority<T_, S_, C_> T;
    template <typename V>
    static void _(const V& val, typename TraitsContainer<T>::ite_t /*ite*/, T& set)
    { set.push(val); }
};

template <typename T_, typename S_, typename C_>
struct Pop<priority<T_, S_, C_> >
{
    typedef priority<T_, S_, C_> T;
    static void _(typename TraitsContainer<T>::ite_t /*ite*/, T& set)
    { set.pop(); }
};

//////////////////////////////////////////////////////////////////////////
NX_END
//////////////////////////////////////////////////////////////////////////
